package com.ssy.lingxi.platform.manage.controller;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.api.model.dto.secret.CheckPasswordDTO;
import com.ssy.lingxi.platform.manage.api.model.vo.secret.SecretKeyVO;
import com.ssy.lingxi.platform.manage.service.SecretKeyService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * @menu 系统能力秘钥管理
 * @author wrc
 * @date 2021/2/26
 * */
@RestController
@RequestMapping("/manage/secret/key")
public class SecretKeyController extends BaseController {

    @Resource
    SecretKeyService secretKeyService;

    /**
     * 查询秘钥
     */
    @GetMapping("/getSecretKey")
    public Wrapper<SecretKeyVO> getSecretKey(HttpServletRequest httpServletRequest){
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return secretKeyService.getSecretKey(sysUser);
    }

    /**
     * 校验秘钥是否正确
     */
    @PostMapping("/checkPassword")
    public Wrapper<Boolean> checkPassword(@Valid @RequestBody CheckPasswordDTO request){
        return secretKeyService.checkPassword(request);
    }
}
